<html>
<head><meta charset="utf-8"><title>Const evaluation · wg-traits · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/index.html">wg-traits</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html">Const evaluation</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="207093811"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207093811" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Ani <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207093811">(Aug 16 2020 at 22:51)</a>:</h4>
<p><span class="user-mention" data-user-id="232957">@Jack Huey</span> I want to take a look at implementing const evaluation in chalk. I'm thinking about starting by supporting some operators in the syntax like <code>&amp;</code>, <code>|</code>, and <code>^</code> (to avoid dealing with overflow for now, later <code>+</code> can be introduced), and folding the constants that can be folded while lowering to chalk-ir. For now, constants in chalk-ir that consist of nontrivial expressions would unify only if their structures are the same (so <code>?A ^ 1</code> wouldn't unify with <code>3</code>, but it would with <code>2 ^ 1</code> (which makes me think twice about folding constants)), though properties of operators can be implemented later.</p>



<a name="207093867"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207093867" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207093867">(Aug 16 2020 at 22:53)</a>:</h4>
<p>Hmm, so, I'm not 100% what needs to be done here</p>



<a name="207093870"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207093870" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207093870">(Aug 16 2020 at 22:53)</a>:</h4>
<p>Let's look at rustc's <code>Const</code>...</p>



<a name="207093918"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207093918" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207093918">(Aug 16 2020 at 22:54)</a>:</h4>
<p>Specifically this: <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.Const.html">https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.Const.html</a></p>



<a name="207093932"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207093932" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207093932">(Aug 16 2020 at 22:54)</a>:</h4>
<p>That's roughly the same as a <code>chalk_ir::ConstData</code></p>



<a name="207093946"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207093946" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207093946">(Aug 16 2020 at 22:55)</a>:</h4>
<p>and <code>chalk_ir::ConstValue</code> is roughly <code>ConstKind</code></p>



<a name="207094016"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207094016" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207094016">(Aug 16 2020 at 22:56)</a>:</h4>
<p>So "supporting const evaluation in Chalk" is roughly supporting the <code>Unevaluated</code> variant</p>



<a name="207094072"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207094072" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207094072">(Aug 16 2020 at 22:58)</a>:</h4>
<p>I'm not sure we 100% know what that's going to look like</p>



<a name="207094217"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207094217" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207094217">(Aug 16 2020 at 23:00)</a>:</h4>
<p>But, I am it'll probably be something like a function on <code>RustIrDatabase</code> that is essentially "try to evaluate this <code>Unevaluated</code> to a <code>ConcreteConst</code>, if you can great, we'll use that; otherwise, we flounder"</p>



<a name="207094234"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207094234" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207094234">(Aug 16 2020 at 23:01)</a>:</h4>
<p>The thing we have to think about is reentrancy</p>



<a name="207094312"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207094312" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207094312">(Aug 16 2020 at 23:02)</a>:</h4>
<p>Because, if I understand it correctly, const eval in rustc goes back and forth with type checking and such</p>



<a name="207100955"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207100955" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Ani <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207100955">(Aug 17 2020 at 02:19)</a>:</h4>
<p>The thing is that right now, chalk doesn't store expressions.</p>



<a name="207106466"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207106466" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Ani <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207106466">(Aug 17 2020 at 04:38)</a>:</h4>
<p>So the <code>Unevaluated</code> equivalent would need some sort of expression type as well as a list of substitutions.</p>



<a name="207150636"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207150636" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207150636">(Aug 17 2020 at 14:30)</a>:</h4>
<p>I'm afraid this is an area of rustc that I know next to nothing about</p>



<a name="207150700"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207150700" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207150700">(Aug 17 2020 at 14:31)</a>:</h4>
<p>In particular, I don't know how <code>Unevaluated</code> relates to the HIR expression</p>



<a name="207150777"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207150777" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207150777">(Aug 17 2020 at 14:32)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@lcnr</span> you're familiar with this, right? Any thoughts?</p>



<a name="207151728"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207151728" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207151728">(Aug 17 2020 at 14:40)</a>:</h4>
<p>I think to support unevaluated constants chalk mostly just needs its own <code>ConstKind::Unevaluated</code></p>



<a name="207151979"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207151979" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207151979">(Aug 17 2020 at 14:42)</a>:</h4>
<p>if you then try to relate 2 unevaluated constants you can "just" evaluate them using const eval and return ambiguous if it fails with <code>TooGeneric</code></p>



<a name="207152061"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207152061" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207152061">(Aug 17 2020 at 14:43)</a>:</h4>
<p>afaict that would mean that you need to include a somewhat large chunk of rustc in chalk to support this though <span aria-label="thinking" class="emoji emoji-1f914" role="img" title="thinking">:thinking:</span></p>



<a name="207152292"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207152292" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207152292">(Aug 17 2020 at 14:45)</a>:</h4>
<p>we currently do not unify generic expressions at all in rustc</p>



<a name="207152393"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207152393" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207152393">(Aug 17 2020 at 14:46)</a>:</h4>
<p>so all of <code>[u8; N + 0]</code>, [u8; N]<code>,  [u8; N &amp; 0xffff_ffff]</code> are distinct types</p>



<a name="207152493"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207152493" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207152493">(Aug 17 2020 at 14:47)</a>:</h4>
<p>presumably, this would go through a database query that's implemented by rustc? so Chalk would just need some way of faking const evaluation for the integration test suite (e.g. something to say "an unevaluated constant that evaluates to x")</p>



<a name="207152533"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207152533" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207152533">(Aug 17 2020 at 14:47)</a>:</h4>
<p>we don't even unify two identical expressions rn, so the following fails to compile (even if we ignore <code>ConstEvaluatable</code> errors for now)</p>
<div class="codehilite"><pre><span></span><code><span class="k">fn</span> <span class="nf">test</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">N</span>: <span class="kt">usize</span><span class="o">&gt;</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="p">[();</span><span class="w"> </span><span class="n">N</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="p">]</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="p">[();</span><span class="w"> </span><span class="n">N</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="p">]</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="207152689"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207152689" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207152689">(Aug 17 2020 at 14:49)</a>:</h4>
<p><span class="user-mention silent" data-user-id="129457">Florian Diebold</span> <a href="#narrow/stream/144729-wg-traits/topic/Const.20evaluation/near/207152493">said</a>:</p>
<blockquote>
<p>presumably, this would go through a database query that's implemented by rustc? so Chalk would just need some way of faking const evaluation for the integration test suite (e.g. something to say "an unevaluated constant that evaluates to x")</p>
</blockquote>
<p>afaict chalk integration would just call <code>ct.eval</code> in the right places and otherwise ignore unevaluated constants.</p>
<p>So yeah, not sure what exactly is a  "database query" but that seems about right to me</p>



<a name="207153189"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207153189" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207153189">(Aug 17 2020 at 14:53)</a>:</h4>
<p>Right, this also fits with my thoughts</p>



<a name="207153300"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207153300" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207153300">(Aug 17 2020 at 14:54)</a>:</h4>
<p>I guess the question is does <code>ConstKind::Unevaluated</code> cover the actual expresssions to generate them? (like <code>N+</code>)</p>



<a name="207153458"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207153458" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207153458">(Aug 17 2020 at 14:55)</a>:</h4>
<p><span class="user-mention silent" data-user-id="216206">lcnr</span> <a href="#narrow/stream/144729-wg-traits/topic/Const.20evaluation/near/207152689">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="129457">Florian Diebold</span> <a href="#narrow/stream/144729-wg-traits/topic/Const.20evaluation/near/207152493">said</a>:</p>
<blockquote>
<p>presumably, this would go through a database query that's implemented by rustc? so Chalk would just need some way of faking const evaluation for the integration test suite (e.g. something to say "an unevaluated constant that evaluates to x")</p>
</blockquote>
<p>afaict chalk integration would just call <code>ct.eval</code> in the right places and otherwise ignore unevaluated constants.</p>
<p>So yeah, not sure what exactly is a  "database query" but that seems about right to me</p>
</blockquote>
<p>Basically this, though.</p>



<a name="207153759"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207153759" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207153759">(Aug 17 2020 at 14:58)</a>:</h4>
<p>I imagine for Chalk, the <code>Unevaluated</code> variant of <code>ConstValue</code> can just be <code>Unevaluated(I::UnevaluatedConst)</code> (or some newtype). Then we can just have a function on <code>RustIrDatabase</code> <code>fn try_evaluate(unevaluated: I::UnevaluatedConst) -&gt; Option&lt;ConcreteConst&lt;I&gt;&gt;</code></p>



<a name="207153779"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207153779" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207153779">(Aug 17 2020 at 14:58)</a>:</h4>
<p>Or maybe <code>Result</code></p>



<a name="207153837"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207153837" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207153837">(Aug 17 2020 at 14:58)</a>:</h4>
<blockquote>
<p>I guess the question is does ConstKind::Unevaluated cover the actual expresssions to generate them?</p>
</blockquote>
<p>not completely sure what you mean here, but from what I can tell the answer is no. <code>ConstKind::Unevaluated</code> is mostly just an opaque identifier for an expression</p>



<a name="207153883"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207153883" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207153883">(Aug 17 2020 at 14:59)</a>:</h4>
<p>Okay, that's all that's needed!</p>



<a name="207154061"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207154061" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207154061">(Aug 17 2020 at 14:59)</a>:</h4>
<p>(continuing) For integration tests, <code>I::UnevaluatedConst</code> can just be a <code>u32</code> and <code>try_evaluate</code> could be a no-op returning that</p>



<a name="207154068"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207154068" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207154068">(Aug 17 2020 at 15:00)</a>:</h4>
<p>evaluating a constant has three relevant results. It can either succeed, error <code>[1, 2, 3][3]</code> or still be too generic <code>std::mem::size_of::&lt;T&gt;()</code></p>



<a name="207158533"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207158533" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207158533">(Aug 17 2020 at 15:35)</a>:</h4>
<p><span class="user-mention silent" data-user-id="232957">Jack Huey</span> <a href="#narrow/stream/144729-wg-traits/topic/Const.20evaluation/near/207154061">said</a>:</p>
<blockquote>
<p>(continuing) For integration tests, <code>I::UnevaluatedConst</code> can just be a <code>u32</code> and <code>try_evaluate</code> could be a no-op returning that</p>
</blockquote>
<p>unless we need to test cases where evaluation fails</p>



<a name="207168867"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207168867" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207168867">(Aug 17 2020 at 17:01)</a>:</h4>
<p>We could just make <code>0</code> always unevalutable</p>



<a name="207240199"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207240199" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Areredify <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207240199">(Aug 18 2020 at 09:36)</a>:</h4>
<p>I say we dont support parsing expressions at all in the test suite, instead allowing users to hook into eval via a usual rust function</p>



<a name="207240663"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207240663" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Areredify <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207240663">(Aug 18 2020 at 09:43)</a>:</h4>
<p>so you write something like ‘f(args: Vec&lt;Const&gt;) -&gt; Result&lt;Const, TooGeneric&gt; { Ok(Const::Value(args[0].eval()? + args[1].eval()?) }‘</p>



<a name="207240749"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207240749" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Areredify <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207240749">(Aug 18 2020 at 09:44)</a>:</h4>
<p>probably needs a context passed in, but w/e</p>



<a name="207241064"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207241064" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Areredify <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207241064">(Aug 18 2020 at 09:48)</a>:</h4>
<p>register it with a macro</p>



<a name="207241102"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207241102" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Areredify <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207241102">(Aug 18 2020 at 09:49)</a>:</h4>
<p>and when parsing recover the fn ptr</p>



<a name="207242445"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207242445" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Areredify <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207242445">(Aug 18 2020 at 10:08)</a>:</h4>
<p>I can mentor if we agree on what needs to be done</p>



<a name="207247139"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207247139" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Areredify <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207247139">(Aug 18 2020 at 11:13)</a>:</h4>
<p>at least on the chalk side, that is</p>



<a name="207302775"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207302775" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Ani <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207302775">(Aug 18 2020 at 19:15)</a>:</h4>
<p>I was thinking of just supporting <code>+</code> for mocking purposes, since an unevaluated const is going to be opaque anyway.</p>



<a name="207314705"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207314705" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Ani <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207314705">(Aug 18 2020 at 20:51)</a>:</h4>
<p>When Chalk can't figure out whether there's a solution to a goal or not, should the result be "No possible solution" or "Ambiguous"?</p>



<a name="207362847"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207362847" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207362847">(Aug 19 2020 at 01:55)</a>:</h4>
<p><span class="user-mention" data-user-id="251766">@Areredify</span> I don't understand what you mean? For testing, we need <em>some</em> way to simulate <code>Unevaluated</code></p>



<a name="207362890"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207362890" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207362890">(Aug 19 2020 at 01:56)</a>:</h4>
<p><span class="user-mention" data-user-id="329281">@Joshua Ani</span> I mean, maybe <code>+</code>, but really I think just storing <code>u32</code> as the <code>Unevaluated</code> type is fine. I guess it depends on our tests</p>



<a name="207362897"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207362897" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207362897">(Aug 19 2020 at 01:57)</a>:</h4>
<p>If Chalk can't prove one way or another, it's <code>Ambiguous</code></p>



<a name="207362903"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207362903" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207362903">(Aug 19 2020 at 01:57)</a>:</h4>
<p>If we <em>can</em> prove there is <em>no</em> solution, then that's <code>No possible solution</code></p>



<a name="207365497"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207365497" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Ani <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207365497">(Aug 19 2020 at 02:57)</a>:</h4>
<p>I could have an <code>Option&lt;u32&gt;</code></p>



<a name="207373616"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207373616" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Areredify <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207373616">(Aug 19 2020 at 06:13)</a>:</h4>
<p><span class="user-mention" data-user-id="232957">@Jack Huey</span> my idea is to not parse <code>+</code> or <code>^</code> at all</p>



<a name="207374027"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207374027" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Areredify <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207374027">(Aug 19 2020 at 06:23)</a>:</h4>
<p>and instead use something like </p>
<div class="codehilite"><pre><span></span><code><span class="k">fn</span> <span class="nf">f</span><span class="p">(</span><span class="n">context</span>: <span class="kp">&amp;</span><span class="nc">Context</span><span class="p">,</span><span class="w"> </span><span class="n">args</span>: <span class="nb">Vec</span><span class="o">&lt;</span><span class="n">Const</span><span class="o">&gt;</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nb">Result</span><span class="o">&lt;</span><span class="n">Const</span><span class="p">,</span><span class="w"> </span><span class="n">TooGeneric</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="nb">Ok</span><span class="p">(</span><span class="n">Const</span>::<span class="n">Value</span><span class="p">(</span><span class="n">args</span><span class="p">[</span><span class="mi">0</span><span class="p">].</span><span class="n">eval</span><span class="p">()</span><span class="o">?</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">args</span><span class="p">[</span><span class="mi">1</span><span class="p">].</span><span class="n">eval</span><span class="p">()</span><span class="o">?</span><span class="p">)</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="n">register</span><span class="o">!</span><span class="p">(</span><span class="n">f</span><span class="p">);</span><span class="w"></span>

<span class="cp">#[test]</span><span class="w"></span>
<span class="k">fn</span> <span class="nf">test</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">test</span><span class="o">!</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">       </span><span class="n">program</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">           </span><span class="k">struct</span> <span class="nc">Array</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">N</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">           </span><span class="p">}</span><span class="w"></span>
<span class="w">           </span><span class="o">..</span><span class="p">.</span><span class="w"></span>
<span class="w">           </span><span class="k">trait</span><span class="w"> </span><span class="n">Foo</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="w">           </span><span class="k">impl</span><span class="w"> </span><span class="n">Foo</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">Array</span><span class="o">&lt;</span><span class="mi">3</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="w">       </span><span class="p">}</span><span class="w"></span>
<span class="w">       </span><span class="n">goal</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">           </span><span class="n">Array</span><span class="o">&lt;</span><span class="n">f</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="mi">2</span><span class="p">)</span><span class="o">&gt;</span>: <span class="nc">Foo</span><span class="w"></span>
<span class="w">       </span><span class="p">}</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="207376000"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207376000" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207376000">(Aug 19 2020 at 06:59)</a>:</h4>
<p><span class="user-mention" data-user-id="251766">@Areredify</span> but what does that allow us to test that simply writing <code>unevaluated(3)</code> doesn't?</p>



<a name="207382296"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207382296" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Areredify <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207382296">(Aug 19 2020 at 08:34)</a>:</h4>
<p>Because <code>f</code> might depend on other unevaluated constants</p>



<a name="207382620"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207382620" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Areredify <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207382620">(Aug 19 2020 at 08:39)</a>:</h4>
<p>im not sure whats legal, const generics rfc doesnt talk much about traits I think (?)</p>



<a name="207382690"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207382690" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207382690">(Aug 19 2020 at 08:40)</a>:</h4>
<p>but how does that affect Chalk, when Chalk can anyhow only see whether the constant got evaluated or not?</p>



<a name="207382864"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207382864" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Areredify <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207382864">(Aug 19 2020 at 08:42)</a>:</h4>
<p>If you mean this test in particular, unevaluated(3) is better, yes</p>



<a name="207382879"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207382879" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207382879">(Aug 19 2020 at 08:43)</a>:</h4>
<p>I mean in general</p>



<a name="207382886"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207382886" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Areredify <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207382886">(Aug 19 2020 at 08:43)</a>:</h4>
<p>maybe Im thinking that const generics are more powerful that they are</p>



<a name="207382894"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207382894" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Areredify <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207382894">(Aug 19 2020 at 08:43)</a>:</h4>
<p>is this legal? <code>struct S&lt;const N&gt; where Vec&lt;u32&gt;: Foo&lt;f(N, N)&gt; {}</code></p>



<a name="207382978"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207382978" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Areredify <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207382978">(Aug 19 2020 at 08:44)</a>:</h4>
<p>*should it be legal</p>



<a name="207382994"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207382994" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207382994">(Aug 19 2020 at 08:44)</a>:</h4>
<p>it's probably not currently legal, but I don't think that matters that much -- I assume it's something we want to be legal at some point</p>



<a name="207383016"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207383016" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207383016">(Aug 19 2020 at 08:45)</a>:</h4>
<p>I just don't see why it makes a difference to Chalk</p>



<a name="207383140"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207383140" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Areredify <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207383140">(Aug 19 2020 at 08:46)</a>:</h4>
<p>say, f(N, N) = 2N, how would your variant look then?</p>



<a name="207383148"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207383148" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207383148">(Aug 19 2020 at 08:46)</a>:</h4>
<p><span class="user-mention silent" data-user-id="251766">Areredify</span> <a href="#narrow/stream/144729-wg-traits/topic/Const.20evaluation/near/207382894">said</a>:</p>
<blockquote>
<p>is this legal? <code>struct S&lt;const N&gt; where Vec&lt;u32&gt;: Foo&lt;f(N, N)&gt; {}</code></p>
</blockquote>
<p>This will require const wf bounds and will be implemented soon, but doesn't really interact with the trait system apart from returning <code>TooGeneric</code>, <code>ConstKind::Value</code> or an error</p>



<a name="207383292"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207383292" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Areredify <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207383292">(Aug 19 2020 at 08:48)</a>:</h4>
<p>by your variant I mean how do WellFormed clauses look</p>



<a name="207383302"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207383302" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207383302">(Aug 19 2020 at 08:48)</a>:</h4>
<p>you probably need a way to specify that a const returns <code>Ok</code> for one value of <code>N</code> and an error for a different value.</p>



<a name="207383356"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207383356" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207383356">(Aug 19 2020 at 08:49)</a>:</h4>
<p>I don't know how to best test this in chalk myself <span aria-label="thinking" class="emoji emoji-1f914" role="img" title="thinking">:thinking:</span></p>



<a name="207383432"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207383432" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207383432">(Aug 19 2020 at 08:50)</a>:</h4>
<p>I can only explain how this will work in rustc</p>



<a name="207383438"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207383438" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Areredify <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207383438">(Aug 19 2020 at 08:50)</a>:</h4>
<p><span class="user-mention silent" data-user-id="216206">lcnr</span> <a href="#narrow/stream/144729-wg-traits/topic/Const.20evaluation/near/207383302">said</a>:</p>
<blockquote>
<p>you probably need a way to specify that a const returns <code>Ok</code> for one value of <code>N</code> and an error for a different value.</p>
</blockquote>
<p>thats sort of what I want to accomplish</p>



<a name="207383466"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207383466" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Areredify <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207383466">(Aug 19 2020 at 08:50)</a>:</h4>
<p>and also that it can return Ok even if one of parameters is generic</p>



<a name="207436421"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207436421" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207436421">(Aug 19 2020 at 17:21)</a>:</h4>
<p>I honestly think that for tests we just need something like <code>3</code> or <code>unevaluated(3)</code></p>



<a name="207436654"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207436654" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207436654">(Aug 19 2020 at 17:23)</a>:</h4>
<p>at least, it seems to make sense to start with that until we actually come up with a test case that requires more?</p>



<a name="207437803"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207437803" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Ani <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207437803">(Aug 19 2020 at 17:33)</a>:</h4>
<p>I opened a pull request: <a href="https://github.com/rust-lang/chalk/pull/596">https://github.com/rust-lang/chalk/pull/596</a></p>



<a name="207438280"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207438280" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207438280">(Aug 19 2020 at 17:37)</a>:</h4>
<p>Wow, unexpected</p>



<a name="207438435"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207438435" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207438435">(Aug 19 2020 at 17:38)</a>:</h4>
<p><code>unevaluated_impl_generic</code> test fails?</p>



<a name="207438893"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207438893" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Ani <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207438893">(Aug 19 2020 at 17:42)</a>:</h4>
<p>I just fixed that one locally.</p>



<a name="207439019"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207439019" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207439019">(Aug 19 2020 at 17:43)</a>:</h4>
<p>I'm gonna take a quick pass of review for any initial thoughts, but I won't be able to look deeply right now</p>



<a name="207439249"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207439249" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Ani <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207439249">(Aug 19 2020 at 17:45)</a>:</h4>
<p>I noticed that the <code>placeholders_eq</code> test in test/constants.rs has 1 const test and 3 type tests. If I change them all to const tests, then</p>
<div class="codehilite"><pre><span></span><code>exists&lt;const C&gt; {
    forall&lt;const D&gt; {
        C = D
    }
}
</code></pre></div>


<p>returns the substitution <code>?0 := !1_0</code> instead of no solution. Should I leave them as type tests or actually try to fix them?</p>



<a name="207439413"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207439413" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207439413">(Aug 19 2020 at 17:46)</a>:</h4>
<p>Oh interesting. Seems like an oversight</p>



<a name="207439437"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207439437" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207439437">(Aug 19 2020 at 17:47)</a>:</h4>
<p>Um, let me think about that</p>



<a name="207439586"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207439586" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Ani <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207439586">(Aug 19 2020 at 17:48)</a>:</h4>
<p>I'll open an issue for now</p>



<a name="207439651"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207439651" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207439651">(Aug 19 2020 at 17:48)</a>:</h4>
<p>That works</p>



<a name="207439861"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207439861" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207439861">(Aug 19 2020 at 17:50)</a>:</h4>
<p>Seems like something is wrong, since we should be getting <code>No solution</code> for consts too (though I have to convince myself why)</p>



<a name="207442845"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/207442845" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#207442845">(Aug 19 2020 at 18:17)</a>:</h4>
<p>Left some comments</p>



<a name="208246303"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/208246303" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#208246303">(Aug 27 2020 at 17:04)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> around?</p>



<a name="208246375"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Const%20evaluation/near/208246375" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Const.20evaluation.html#208246375">(Aug 27 2020 at 17:04)</a>:</h4>
<p>I know you're pretty swamped, but was wondering you could take a quick look at <a href="https://github.com/rust-lang/chalk/pull/598">https://github.com/rust-lang/chalk/pull/598</a></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>